Windows 上透過 WSL 進入 Ubuntu shell
在 Windows 上透過 WSL (Windows Subsystem for Linux) 進入 Ubuntu shell,其實只需要在命令提示字元 (CMD) 或 PowerShell 執行對應的指令即可。以下是完整的方式:
wsl
wsl -d Ubuntu
如果你安裝的是 Ubuntu 20.04 或 22.04,名稱可能是
Ubuntu-20.04或Ubuntu-22.04。
wsl -d Ubuntu -u root
執行:
wsl --list --verbose
或簡寫:
wsl -l -v
會列出所有已安裝的 Linux 發行版,例如:
NAME STATE VERSION
* Ubuntu-22.04 Running 2
Debian Stopped 2
其中 * 表示預設發行版。
wsl --set-default Ubuntu-22.04
之後只要輸入 wsl 就會直接進入 Ubuntu shell。exit
[開始]
↓
打開 CMD 或 PowerShell
↓
輸入指令:
├─ 如果 Ubuntu 已設為預設 → wsl
├─ 如果要指定版本 → wsl -d Ubuntu-22.04
└─ 如果要指定使用者 → wsl -d Ubuntu-22.04 -u root
↓
[進入 Ubuntu Shell]
↓
輸入 exit 可返回 Windows
wsl -l -v 查看已安裝的 Linux 發行版Ubuntu-20.04、Ubuntu-22.04wsl -d Ubuntu-22.04 -u rootwsl --set-default Ubuntu-22.04exit 回到 Windows這樣你就能用一張表快速判斷要輸入哪個指令。
要不要我再幫你做一份 多發行版切換對照表,例如同時安裝了 Ubuntu、Debian、Kali 時,如何快速切換?
| File1 | File | Last Modified |
|---|---|---|
| 在WSL 中安裝 Ubuntu | 在WSL 中安裝 Ubuntu | 8:21 PM - December 06, 2025 |